package com.foton.lotterydomain.activity.service.stateflow.event;

import com.foton.lotterycommon.common.Constants;
import com.foton.lotterycommon.common.Result;
import com.foton.lotterydomain.activity.service.stateflow.AbstractState;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author RenPu
 * @Date 2023/12/1 17:22
 * @Version 1.0
 * @Description: 活动提审 -具体实现类
 **/

@Component
public class ArraignmentState extends AbstractState {

    // 待审核单据，可以执行的流程节点为：审核通过，审核拒绝，活动审核撤销，活动审核关闭

    @Override
    public Result arraignment(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("待审核状态不可重复提审");
    }

    @Override
    public Result checkPass(Long activityId, Enum<Constants.ActivityState> currentState) {
        boolean updateResult = activityRepository.alterStatus(activityId, currentState, Constants.ActivityState.PASS);
        return updateResult ? Result.buildResult(Constants.ResponseCode.SUCCESS.getCode(), "活动审核通过完成！！！！") : Result.buildErrorResult("活动状态变更失败");
    }

    @Override
    public Result checkRefuse(Long activityId, Enum<Constants.ActivityState> currentState) {
        boolean updateResult = activityRepository.alterStatus(activityId, currentState, Constants.ActivityState.REFUSE);
        return updateResult ? Result.buildResult(Constants.ResponseCode.SUCCESS.getCode(), "活动拒绝通过完成！！！！") : Result.buildErrorResult("活动状态变更失败");
    }

    @Override
    public Result checkRevoke(Long activityId, Enum<Constants.ActivityState> currentState) {
        boolean updateResult = activityRepository.alterStatus(activityId, currentState, Constants.ActivityState.REVOKE);
        return updateResult ? Result.buildResult(Constants.ResponseCode.SUCCESS.getCode(), "活动撤审通过完成！！！！") : Result.buildErrorResult("活动状态变更失败");

    }

    @Override
    public Result close(Long activityId, Enum<Constants.ActivityState> currentState) {
        boolean updateResult = activityRepository.alterStatus(activityId, currentState, Constants.ActivityState.CLOSE);
        return updateResult ? Result.buildResult(Constants.ResponseCode.SUCCESS.getCode(), "活动关闭通过完成！！！！") : Result.buildErrorResult("活动状态变更失败");

    }

    @Override
    public Result open(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("非关闭活动不可开启");
    }


    @Override
    public Result doing(Long activityId, Enum<Constants.ActivityState> currentState) {
        return Result.buildErrorResult("待审核活动不可执行活动中变更");
    }
}
